<template>
  <view>
    <cu-custom bgColor="" :isBack="true" bgColor="bg-white">
      <view slot="backText">返回</view>
      <view slot="content">主角等级</view>
    </cu-custom>
    <ad unit-id="adunit-2ba0fc6d0c82bc24" ad-type="video" ad-theme="white"></ad>
    <view class="margin-top card">
      <view class="cu-form-group">
        <view class="title">当前等级</view>
        <input type="number" v-model="level1" placeholder="请输入当前等级"></input>
      </view>
      <view class="cu-form-group">
        <view class="title">提升等级</view>
        <input type="number" v-model="level2" placeholder="你想提升到多少级?"></input>
      </view>
      <view class="cu-form-group">
        <view class="title">体力丹数</view>
        <input type="number" v-model="number2" placeholder="你目前拥有的体力丹数量"></input>
        <button class="cu-btn bg-green shadow" @click="calc">Go!</button>
      </view>
      <view class="cu-form-group">
        <view class="title"></view>
        <input disabled></input>
      </view>
      <view class="cu-form-group">
        <view class="title"></view>
        <input disabled></input>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        level1: "",
        level2: "",
        number: [0.2, 0.2, 0.2, 0.2, 0.4, 0.4, 0.4, 0.6, 1, 1, 1.2, 1.2, 1.4, 1.6, 2.4, 3.4, 4.4, 4.8, 5, 5, 5.2, 5.4, 5.6, 5.8, 6, 6.2, 6.4, 6.8, 7.2, 7.6, 8, 8.4, 8.6, 8.8, 9, 9.2, 9.4, 9.6, 9.8, 11.4, 14.4, 17.4, 20.4, 23.4, 27.4, 28.6, 29.2, 29.8, 30.4, 31, 31.6, 32.2, 32.8, 33.4, 34, 34.6, 35.2, 35.8, 36.4, 37, 37.6, 38.2, 38.8, 39.4, 40, 40.6, 41.2, 41.8, 42.4, 43, 43.6, 44.2, 44.8, 45.4, 46, 46.6, 47.2, 47.8, 48.4, 70.56, 97.2, 128.5, 164.6, 205.6, 208, 210.4, 212.8, 215.2, 217.6, 220, 222.4, 224.8, 227.2, 229.6, 232, 234.4, 236.8, 239.2, 241.6, 244, 246.4, 248.8, 251.2, 253.6, 256, 258.4, 260.8, 263.2, 265.6, 268, 270.4, 272.8, 275.2, 277.6, 280, 282.4, 284.8, 287.2, 289.6, 292, 294.4, 296.8, 299.2, 301.6, 304, 306.4, 308.8, 311.2, 313.6, 316, 318.4, 320.8, 323.2, 325.6, 328, 330.4, 332.8, 335.2, 337.6, 340, 342.4, 344.8, 347.2, 349.6, 352, 354.4, 356.8, 359.2, 361.6, 364, 366.4, 368.8, 371.2, 373.6, 376, 378.4, 380.8, 383.2, 385.6, 388, 390.4, 392.8, 395.2, 397.6, 400, 402.4, 404.8, 407.2, 409.6, 412, 414.4, 416.8, 419.2, 421.6, 424, 426.4, 428.8, 431.2, 433.6, 436, 438.4, 440.8, 443.2, 445.6, 448, 450.4, 452.8, 455.2, 457.6, 460, 462.4, 464.8, 467.2, 469.6, 472, 474.4, 476.8, 479.2, 481.6, 484, 486.4, 488.8, 491.2, 493.6, 496, 498.4, 500.8, 503.2, 505.6, 508, 510.4, 512.8, 515.2, 517.6, 520, 522.4, 524.8, 527.2, 529.6, 532],
        number2: "",
        sum: 0
      }
    },
    onLoad() {
    },
    methods: {
      calc() {
        if (this.level2 * 1 <= this.level1 * 1) {
          uni.showToast({
            title: "兄得, 好好输入, 别瞎搞~",
            icon: "none"
          })
          return
        }
        if (this.level1 > 220 || this.level2 > 220) {
          uni.showToast({
            title: "兄得, 我只能算220级以内的加减法哦~",
            icon: "none"
          })
          return
        }
        let arr = this.number.slice(this.level1 - 1, this.level2 - 1)
        this.sum = 0
        for (let i = 0; i < arr.length; i++) {
          this.sum += arr[i]
        }
        uni.showModal({
          title: "小伙子",
          content: `你从${this.level1}级升到${this.level2}级还需要${(this.sum - this.number2).toFixed(1)}个体力丹`,
          showCancel: false
        })
      }
    }
  }
</script>

<style scoped>
  .card {
    background-image: url('https://mmbiz.qpic.cn/mmbiz_jpg/8iaIEbCVSqJZfILHPjJVoekw9ic8GfibSCib86xVIL2Ml9k8OcshZx0dOSBGtE86iaJXOib20MV6qaNYO5icrSvj9D8GQ/640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1&wx_co=1');
    background-size: cover;
    background-position: center center;
  }

  .cu-form-group {
    background-color: rgba(255, 255, 255, 0.8);
  }
</style>
